<?
class db
{
    /**
     * @var array private db settings
     */
    private static $conf = array();

    /**
     * @var mysql-link resource
     */
    private static $link;

    /**
     * connect to db
     * @param $conf like array('host' => 'localhost', 'user' => 'root', etc)
     * @return bool == true if connect and select_db ok : false if has a some error
     */
    public static function connect($conf)
    {
        $short_host = !empty($conf['host']) && !empty($conf['port']) ? $conf['host'].':'.$conf['port'] : '';

        if (!empty($conf['host']) && !empty($conf['user']) && !empty($conf['password'])&& !empty($conf['port']) && !empty($conf['port']) && !empty($conf['prefix']) && (self::$link = mysql_connect($short_host, $conf['user'], $conf[''])))
        {
            if (!empty($conf['schema']) && mysql_select_db($conf, self::$link))
            {
                self::$conf = $conf;
                return true;
            }
            else
            {
                // db schema not found
                // todo add error control
            }
        }
        else
        {
            // db host not found
            // todo add error control
        }
        return false;
    }
}
